﻿using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Model;
using System.Data;

namespace University.Workshop.Tests
{
    
    [TestClass()]
    public class SaleDataAccessTest
    {


        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        [TestMethod()]
        public void SaleRegisterTest()
        {
            Sale sale = new Sale();
            sale.Code = "20000";
            sale.ClientCode = "101010";
            sale.DateSale=DateTime.Now;
            sale.UserCode = "1";
            sale.TotalAmount="50";
            bool expected = true; 
            bool actual;
            actual = SaleDataAccess.SaleRegister(sale);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void SaleDetailRegisterTest()
        {
            SaleDetail saleDetail = new SaleDetail();
            saleDetail.CodeSale = "20000";
            saleDetail.CodeProduct = "med003";
            saleDetail.Quantity = 1;
            saleDetail.UnitPrice = 50;
            saleDetail.TotalPrice = 50;
            bool expected = true; 
            bool actual;
            actual = SaleDataAccess.SaleDetailRegister(saleDetail);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void GetProductRowTest()
        {
            string productCode = "med001";
            DataTable actual;
            actual = SaleDataAccess.GetProductRow(productCode);
            Assert.IsNotNull(actual);
        }

        [TestMethod()]
        public void GetSaleCodeTest()
        {
            //string nothing = "nothing";
            DataTable actual;
            actual = SaleDataAccess.GetSaleCode();
            Assert.IsNotNull(actual);
        }
    }
}
